package top.techqi.app.wol.db.dao

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.Query
import top.techqi.app.wol.db.tbl.Device

@Dao
interface DeviceDao {
    @Query("SELECT * FROM devices")
    suspend fun getAllDevices(): List<Device>

    @Query("SELECT * FROM devices WHERE id=:id")
    suspend fun getDeviceById(id: Int): Device?

    @Query("DELETE FROM devices WHERE id=:id")
    suspend fun delDevice(id: Int)

    @Insert
    suspend fun addDevice(device: Device)

    @Delete
    suspend fun delDevice(device: Device)

    @Query("UPDATE devices SET icon=:icon, name=:name, addr=:addr WHERE id=:id")
    suspend fun updateDevice(id: Int, icon: String?, name: String, addr: String)
}